
#ifndef TOUCH_CONTROLLER_H
#define TOUCH_CONTROLLER_H

// INCLUDES ********************************************************************

#include "Vector2D.h"

#include "Singleton.h"

#include "TouchListener.h"

#include <set>

// FORWARD DECLARATIONS ********************************************************

namespace Meteor
{
    class Drawable;
}

/*******************************************************************************
 
 TODO:  - gestures
 
*******************************************************************************/

// *****************************************************************************

//! TouchController
//! 
//! Will receive touch notifications from the OpenGL view and delegate them to 
//! registered listeners

// *****************************************************************************

namespace Meteor 
{
    class TouchController : public Singleton<TouchController>
    {
        friend class Singleton<TouchController>;
        
        public:
            void TouchBegan( const Vector2D& position);
        
            void TouchMoved( const Vector2D& position);
        
            void TouchEnded( const Vector2D& position);
        
            void AddTouchListener( TouchListener* listener);
        
            void RemoveTouchListener( TouchListener* listener);
        
        private:
            typedef std::set<TouchListener*> containertype;
        
            containertype mListeners;
        
            //! values in nanoseconds, will have to be used with
            //! Timer::ConversionFactor
            uint64_t mTouchStartTime;
        
            uint64_t mTouchEndTime;
        
            uint64_t mTouchDuration;
        
            TouchController();
        
            TouchController( const TouchController&);
            
            //! prevent copies
            const TouchController& operator=( const TouchController&);
            
            ~TouchController();
        
    }; // end of class TouchController

} // end of namespace Meteor

#endif
